package me.softwareengineer.guice.rendering.domain;

import java.util.List;
import java.util.Map;

import me.softwareengineer.guice.rendering.listener.EndTableCellEvent;
import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.StartTableCellEvent;

/**
 * Represents a cell of a table.
 * 
 * @author yad.tahir
 * 
 *         <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 */
public class TableCellElement extends Element {

	/**
	 * Creates a table cell
	 * 
	 * @param children
	 *            the sub elements of the cell. For more info, check
	 *            {@link HasChildren}
	 * @param properties
	 *            the properties of the cell. For more info, check
	 *            {@link HasProperties}
	 */
	public TableCellElement(List<Element> children,
			Map<String, String> properties) {
		super(children, properties);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void afterElement(Listener listener) {
		EndTableCellEvent e = new EndTableCellEvent(getAllProperties());
		listener.onEvent(e);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void beforeElement(Listener listener) {
		StartTableCellEvent e = new StartTableCellEvent(getAllProperties());
		listener.onEvent(e);
	}
}
